<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- This document is an unofficial reference manual for LaTeX, a
document preparation system, version of October 2018.

This manual was originally translated from LATEX.HLP v1.0a in the
VMS Help Library.  The pre-translation version was written by
George D. Greenwade of Sam Houston State University.  The
LaTeX 2.09 version was written by Stephen Gilmore.  The
LaTeX2e version was adapted from this by Torsten Martinsen.  Karl
Berry made further updates and additions, and gratefully acknowledges
using Hypertext Help with LaTeX, by Sheldon Green, and
LaTeX Command Summary (for LaTeX 2.09) by
L. Botway and C. Biemesderfer (published by the TeX Users
Group as TeXniques number 10), as reference material.  We also
gratefully acknowledge additional material appearing in
latex2e-reference by Martin Herbert Dietze.  (From these references no
text was directly copied.)

Copyright 2007, 2008, 2009, 2010, 2011, 2012, 2013,
2014, 2015, 2016, 2017, 2018 Karl Berry.

Copyright 1988, 1994, 2007 Stephen Gilmore.

Copyright 1994, 1995, 1996 Torsten Martinsen.

Permission is granted to make and distribute verbatim copies of
this manual provided the copyright notice and this permission notice
are preserved on all copies.


Permission is granted to copy and distribute modified versions of this
manual under the conditions for verbatim copying, provided that the entire
resulting derived work is distributed under the terms of a permission
notice identical to this one.

Permission is granted to copy and distribute translations of this manual
into another language, under the above conditions for modified versions. -->
<!-- Created by GNU Texinfo 6.5, http://www.gnu.org/software/texinfo/ -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Color (LaTeX2e unofficial reference manual (October 2018))</title>

<meta name="description" content="Color (LaTeX2e unofficial reference manual (October 2018))">
<meta name="keywords" content="Color (LaTeX2e unofficial reference manual (October 2018))">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<link href="latex2e_0.html#Top" rel="start" title="Top">
<link href="latex2e_30.html#Index" rel="index" title="Index">
<link href="latex2e_0.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="latex2e_0.html#Top" rel="up" title="Top">
<link href="latex2e_22.html#Graphics" rel="next" title="Graphics">
<link href="latex2e_20.html#g_t_005cusebox" rel="prev" title="\usebox">
<style type="text/css">
<!--
body {margin: 1em; margin-top: 0px; padding-top: 1px}
a.anchor {float: right}
a:visited {color: #00e}
a:active {color: #000}
a.external {background: url('./images/external-link.png') no-repeat; background-position: right center; padding-right: 18px}
a.summary-letter {text-decoration: none}
blockquote.indentedblock {margin-right: 0em}
blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
blockquote.smallquotation {font-size: smaller}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
div.smalldisplay {margin-left: 3.2em}
div.smallexample {margin-left: 3.2em}
div.smalllisp {margin-left: 3.2em}
kbd {font-style: oblique}
pre.display {font-family: inherit}
pre.format {font-family: inherit}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: inherit; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: inherit; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.nolinebreak {white-space: nowrap}
span.roman {font-family: initial; font-weight: normal}
span.sansserif {font-family: sans-serif; font-weight: normal}
ul.no-bullet {list-style: none}
-->
</style>


</head>

<body id="top" lang="en">
<a name="Color" class="anchor"></a>
<a name="Color-1" class="anchor"></a>
<h2 class="chapter">Color</h2>

<a name="index-color" class="anchor"></a>

<p>You can add color to text, rules, etc.  You can also have color in a box
or on an entire page and write text on top of it.
</p>
<p>Color support comes as an additional package.  So put
<code>\usepackage{color}</code> in your document preamble to use the
commands described here.
</p>
<p>Many other packages also supplement LaTeX&rsquo;s color abilities.
Particularly worth mentioning is <samp>xcolor</samp>, which is widely used and
significantly extends the capabilities described here, including adding
&lsquo;<samp>HTML</samp>&rsquo; and &lsquo;<samp>Hsb</samp>&rsquo; color models.
</p>


<hr>
<a name="Color-package-options" class="anchor"></a>
<a name="color-package-options" class="anchor"></a>
<h3 class="section"><code>color</code> package options</h3>

<a name="index-color-package-options" class="anchor"></a>
<a name="index-options_002c-color-package" class="anchor"></a>

<p>Synopsis (must be in the document preamble):
</p>
<div class="example">
<pre class="example">\usepackage[<var>comma-separated option list</var>]{color}
</pre></div>

<p>When you load the <samp>color</samp> package there are two kinds of available
options.
</p>
<p>The first specifies the <em>printer driver</em>.  LaTeX doesn&rsquo;t contain
information about different output systems but instead depends on
information stored in a file.  Normally you should not specify the
driver option in the document, and instead rely on your system&rsquo;s
default. One advantage of this is that it makes the document portable
across systems.  For completeness we include a list of the drivers.  The
currently relevant ones are: <samp>dvipdfmx</samp>, <samp>dvips</samp>,
<samp>dvisvgm</samp>, <samp>luatex</samp>, <samp>pdftex</samp>, <samp>xetex</samp>.  The two
<samp>xdvi</samp> and <samp>oztex</samp> are essentially aliases for <samp>dvips</samp>
(and <samp>xdvi</samp> is monochrome).  Ones that should not be used for new
systems are: <samp>dvipdf</samp>, <samp>dvipdfm</samp>, <samp>dviwin</samp>,
<samp>dvipsone</samp>, <samp>emtex</samp>, <samp>pctexps</samp>, <samp>pctexwin</samp>,
<samp>pctexhp</samp>, <samp>pctex32</samp>, <samp>truetex</samp>, <samp>tcidvi</samp>,
<samp>vtex</samp> (and <samp>dviwindo</samp> is an alias for <samp>dvipsone</samp>).
</p>
<p>The second kind of options, beyond the drivers, are below.
</p>
<dl compact="compact">
<dt><code>monochrome</code></dt>
<dd><p>Disable the color commands, so that they do not generate errors but do
not generate color either.
</p>
</dd>
<dt><code>dvipsnames</code></dt>
<dd><p>Make available a list of 68 color names that are often used,
particularly in legacy documents.  These color names were originally
provided by the <samp>dvips</samp> driver, giving the option name.
</p>
</dd>
<dt><code>nodvipsnames</code></dt>
<dd><p>Do not load that list of color names, saving LaTeX a tiny amount of
memory space.
</p>
</dd>
</dl>


<hr>
<a name="Color-models" class="anchor"></a>
<a name="Color-models-1" class="anchor"></a>
<h3 class="section">Color models</h3>

<a name="index-color-models" class="anchor"></a>

<p>A <em>color model</em> is a way of representing colors.  LaTeX&rsquo;s
capabilities depend on the printer driver.  However, the <samp>pdftex</samp>,
<samp>xetex</samp>, and <samp>luatex</samp> printer drivers are today by far the
most commonly used.  The models below work for those drivers.  All but
one of these is also supported by essentially all other printer drivers
used today.
</p>
<p>Note that color combination can be additive or subtractive.  Additive
mixes colors of light, so that for instance combining full intensities
of red, green, and blue produces white.  Subtractive mixes pigments,
such as with inks, so that combining full intensity of cyan, magenta,
and yellow makes black.
</p>
<dl compact="compact">
<dd><a name="color-models-cmyk" class="anchor"></a></dd>
<dt><code>cmyk</code></dt>
<dd><p>A comma-separated list with four real numbers between 0 and 1,
inclusive.  The first number is the intensity of cyan, the second is
magenta, and the others are yellow and black.  A number value of 0 means
minimal intensity, while a 1 is for full intensity.  This model is often
used in color printing.  It is a subtractive model.
</p>
<a name="color-models-gray" class="anchor"></a></dd>
<dt><code>gray</code></dt>
<dd><p>A single real number between 0 and 1, inclusive.  The colors are shades
of grey.  The number 0 produces black while 1 gives white.
</p>
<a name="color-models-rgb" class="anchor"></a></dd>
<dt><code>rgb</code></dt>
<dd><p>A comma-separated list with three real numbers between 0 and 1,
inclusive.  The first number is the intensity of the red component, the
second is green, and the third the blue.  A number value of 0 means that
none of that component is added in, while a 1 means full intensity.
This is an additive model.
</p>
<a name="color-models-RGB" class="anchor"></a></dd>
<dt><code>RGB</code></dt>
<dd><p>(<samp>pdftex</samp>, <samp>xetex</samp>, <samp>luatex</samp> drivers) A comma-separated
list with three integers between 0 and 255, inclusive.  This model is a
convenience for using <code>rgb</code> since outside of LaTeX colors are
often described in a red-green-blue model using numbers in this range.
The values entered here are converted to the <code>rgb</code> model by
dividing by 255.
</p>
<a name="color-models-named" class="anchor"></a></dd>
<dt><code>named</code></dt>
<dd><p>Colors are accessed by name, such as &lsquo;<samp>PrussianBlue</samp>&rsquo;.  The list of
names depends on the driver, but all support the names &lsquo;<samp>black</samp>&rsquo;,
&lsquo;<samp>blue</samp>&rsquo;, &lsquo;<samp>cyan</samp>&rsquo;, &lsquo;<samp>green</samp>&rsquo;, &lsquo;<samp>magenta</samp>&rsquo;, &lsquo;<samp>red</samp>&rsquo;,
&lsquo;<samp>white</samp>&rsquo;, and &lsquo;<samp>yellow</samp>&rsquo; (See the <code>dvipsnames</code> option in
<a href="#Color-package-options">Color package options</a>).
</p>
</dd>
</dl>


<hr>
<a name="Commands-for-color" class="anchor"></a>
<a name="Commands-for-color-1" class="anchor"></a>
<h3 class="section">Commands for color</h3>

<a name="index-color-package-commands" class="anchor"></a>

<p>These are the commands available with the <samp>color</samp> package.
</p>


<hr>
<a name="Define-colors" class="anchor"></a>
<a name="Define-colors-1" class="anchor"></a>
<h4 class="subsection">Define colors</h4>

<a name="index-color-1" class="anchor"></a>
<a name="index-define-color" class="anchor"></a>
<a name="index-color_002c-define" class="anchor"></a>

<p>Synopsis:
</p>
<div class="example">
<pre class="example">\definecolor{<var>name</var>}{<var>model</var>}{<var>specification</var>}
</pre></div>

<p>Give the name <var>name</var> to the color.  For example, after this
</p>
<div class="example">
<pre class="example">\definecolor{silver}{rgb}{0.75,0.75,0.74}
</pre></div>

<p>you can use that color name with <code>Hi ho,
\textcolor{silver}{Silver}!</code>.
</p>
<p>This example gives the color a more abstract name, so it could change and
not be misleading.
</p>
<div class="example">
<pre class="example">\definecolor{logocolor}{RGB}{145,92,131}    % RGB needs pdflatex
\newcommand{\logo}{\textcolor{logocolor}{Bob's Big Bagels}}
</pre></div>

<p>Often a document&rsquo;s colors are defined in the preamble, or in the class
or style, rather than in the document body.
</p>

<hr>
<a name="Colored-text" class="anchor"></a>
<a name="Colored-text-1" class="anchor"></a>
<h4 class="subsection">Colored text</h4>

<a name="index-color-2" class="anchor"></a>
<a name="index-colored-text" class="anchor"></a>

<p>Synopses:
</p>
<div class="example">
<pre class="example">\textcolor{<var>name</var>}{...}
\textcolor[<var>color model</var>]{<var>color specification</var>}{...}
</pre></div>

<p>or
</p>
<div class="example">
<pre class="example">\color{<var>name</var>}
\color[<var>color model</var>]{<var>specification</var>}
</pre></div>

<p>The affected text gets the color.  This line
</p>
<div class="example">
<pre class="example">\textcolor{magenta}{My name is Ozymandias, king of kings:}
Look on my works, ye Mighty, and despair!
</pre></div>

<p>causes the first half to be in magenta while the rest is in black.  You
can use a color declared with <code>\definecolor</code> in exactly the same
way that we just used the builtin color &lsquo;<samp>magenta</samp>&rsquo;.
</p>
<div class="example">
<pre class="example">\definecolor{MidlifeCrisisRed}{rgb}{1.0,0.11,0.0}
I'm thinking about getting a \textcolor{MidlifeCrisisRed}{sports car}.
</pre></div>

<p>The two <code>\textcolor</code> and <code>\color</code> differ in that the first is
a command form, enclosing the text to be colored as an argument.  Often
this form is more convenient, or at least more explicit.  The second
form is a declaration, as in <code>The moon is made of {\color{green}
green} cheese</code>, so it is in effect until the end of the current group
or environment.  This is sometimes useful when writing macros or as
below where it colors everything inside the <code>center</code> environment,
including the vertical and horizontal lines.
</p>
<div class="example">
<pre class="example">\begin{center} \color{blue}
  \begin{tabular}{l|r}
    UL &amp;UR \\ \hline
    LL &amp;LR 
  \end{tabular}
\end{center}
</pre></div>

<p>You can use color in equations.  A document might have this definition
in the preamble
</p>
<div class="example">
<pre class="example">\definecolor{highlightcolor}{RGB}{225,15,0}
</pre></div>

<p>and then contain this equation.
</p>
<div class="example">
<pre class="example">\begin{equation}
  \int_a^b \textcolor{highlightcolor}{f'(x)}\,dx=f(b)-f(a)
\end{equation}
</pre></div>

<p>Typically the colors used in a document are declared in a class or style
but sometimes you want a one-off.  Those are the second forms in the
synopses.
</p>
<div class="example">
<pre class="example">Colors of \textcolor[rgb]{0.33,0.14,0.47}{Purple} and
{\color[rgb]{0.72,0.60,0.37} Gold} for the team.
</pre></div>

<p>The format of <var>color specification </var> depends on the color model
(see <a href="#Color-models">Color models</a>).  For instance, while <code>rgb</code> takes three
numbers, <code>gray</code> takes only one.
</p>
<div class="example">
<pre class="example">The selection was \textcolor[gray]{0.5}{grayed out}.
</pre></div>

<p>Colors inside colors do not combine.  Thus
</p>
<div class="example">
<pre class="example">\textcolor{green}{kind of \textcolor{blue}{blue}}
</pre></div>

<p>has a final word that is blue, not a combination of blue and green.
</p>


<hr>
<a name="Colored-boxes" class="anchor"></a>
<a name="Colored-boxes-1" class="anchor"></a>
<h4 class="subsection">Colored boxes</h4>

<a name="index-color-3" class="anchor"></a>
<a name="index-colored-boxes" class="anchor"></a>
<a name="index-box_002c-colored" class="anchor"></a>

<p>Synopses:
</p>
<div class="example">
<pre class="example">\colorbox{<var>name</var>}{...}
\colorbox[<var>model name</var>]{<var>box background color</var>}{...}
</pre></div>

<p>or
</p>
<div class="example">
<pre class="example">\fcolorbox{<var>frame color</var>}{<var>box background color</var>}{...}
\fcolorbox[<var>model name</var>]{<var>frame color</var>}{<var>box background color</var>}{...}
</pre></div>

<p>Make a box with the stated background color.  The <code>\fcolorbox</code>
command puts a frame around the box.  For instance this
</p>
<div class="example">
<pre class="example">Name:~\colorbox{cyan}{\makebox[5cm][l]{\strut}}
</pre></div>

<p>makes a cyan-colored box that is five centimeters long and gets its
depth and height from the <code>\strut</code> (so the depth is
<code>-.3\baselineskip</code> and the height is <code>\baselineskip</code>).  This
puts white text on a blue background.
</p>
<div class="example">
<pre class="example">\colorbox{blue}{\textcolor{white}{Welcome to the machine.}}
</pre></div>

<p>The <code>\fcolorbox</code> commands use the same parameters as <code>\fbox</code>
(see <a href="latex2e_20.html#g_t_005cfbox-_0026-_005cframebox">\fbox &amp; \framebox</a>), <code>\fboxrule</code> and <code>\fboxsep</code>, to
set the thickness of the rule and the boundary between the box interior
and the surrounding rule.  LaTeX&rsquo;s defaults are <code>0.4pt</code> and
<code>3pt</code>, respectively.
</p>
<p>This example changes the thickness of the border to 0.8 points.  Note
that it is surrounded by curly braces so that the change ends at the end
of the second line.
</p>
<div class="example">
<pre class="example">{\setlength{\fboxrule}{0.8pt}
\fcolorbox{black}{red}{Under no circumstances turn this knob.}}
</pre></div>


<hr>
<a name="Colored-pages" class="anchor"></a>
<a name="Colored-pages-1" class="anchor"></a>
<h4 class="subsection">Colored pages</h4>

<a name="index-color-4" class="anchor"></a>
<a name="index-colored-page" class="anchor"></a>
<a name="index-page_002c-colored" class="anchor"></a>
<a name="index-background_002c-colored" class="anchor"></a>

<p>Synopses:
</p>
<div class="example">
<pre class="example">\pagecolor{<var>name</var>}
\pagecolor[<var>color model</var>]{<var>color specification</var>}
\nopagecolor
</pre></div>

<p>The first two set the background of the page, and all subsequent pages,
to the color.  For an explanation of the specification in the second
form see <a href="#Colored-text">Colored text</a>.  The third returns the background to normal,
which is a transparent background.  (If that is not supported use
<code>\pagecolor{white}</code>, although that will make a white background
rather than the default transparent background.)
</p>
<div class="example">
<pre class="example"> ...
\pagecolor{cyan}
 ...
\nopagecolor
</pre></div>





</body>
</html>
